#pragma once

#include <vector>

#include "util/char-input-stream.h"
#include "md-token.h"


namespace book
{

class MdLineTokenizer
{
public:
    MdLineTokenizer(CharInputStream &in)
        : in_(in) {}

    MdToken next();

private:
    MdToken matchToken(char c);

    MdToken matchFlagToken(char c);

    MdToken matchCodeToken();

    MdToken matchTextToken(char c);

    bool match(const std::string_view &token);

private:
    RestorableCharInputStream in_;
};

class RestorableMdLineTokenizer
{
public:
    RestorableMdLineTokenizer(CharInputStream &in)
        : tokenizer_(in) {}

    MdToken next();

    void pushFront(MdToken &&tok);

private:
    std::vector<MdToken> buffer_;
    MdLineTokenizer tokenizer_;
};

} // namespace book
